import request from "./index";

/**
 * 创建一个好友
 * @param fName {string}
 * @param fDesc {string}
 * @param fLink {string}
 * @param fAvatar {string}
 * @returns {Promise}
 */
export function createFriend(fName, fDesc, fLink, fAvatar) {
  return request({
    url: "/friend",
    method: "POST",
    data: {
      fName,
      fDesc,
      fLink,
      fAvatar
    }
  })
}

/**
 * 获取好友列表
 * @param userId {string | number}
 * @returns {Promise}
 */
export function getFriendList(userId) {
  return request({
    url: "/friend/list",
    params: {
      userId
    }
  })
}

/**
 * 删除一位好友
 * @param friendId {string | number}
 * @returns {Promise}
 */
export function deleteFriend(friendId) {
  return request({
    url: "/friend",
    method: "DELETE",
    data: {
      friendId
    }
  })
}

/**
 * 修改一位好友
 * @param friendId {string | number}
 * @param fName {string}
 * @param fDesc {string}
 * @param fLink {string}
 * @param fAvatar {string}
 * @returns {Promise}
 */
export function updateFriend(friendId, fName, fDesc, fLink, fAvatar) {
  return request({
    url: "friend",
    method: "PATCH",
    data: {
      friendId,
      fName,
      fDesc,
      fLink,
      fAvatar
    }
  })
}

/**
 * 获取好友详情
 * @param friendId {string | number}
 * @returns {Promise}
 */
export function getFriendById(friendId) {
  return request({
    url: "/friend",
    params: {
      friendId
    }
  })
}
